package com.imau.common.entiry;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ResultEntity{

    private boolean success;  //是否成功
    private Integer code;     // 返回码
    private String message;   //返回信息
    private Object data;      // 返回数据

    public ResultEntity(ResultCode code)
    {
        this.success = code.getSuccess();
        this.code = code.getCode();
        this.message=code.getMessage();
    }


    public ResultEntity(ResultCode code,Object data)
    {
        this.success = code.getSuccess();
        this.code = code.getCode();
        this.message=code.getMessage();
        this.data =data;
    }

    public ResultEntity(Integer code,String message,boolean success) {

        this.code = code;
        this.message = message;
        this.success = success;
    }

    public static ResultEntity SUCCESS(){

        return new ResultEntity(ResultCode.SUCCESS);
    }

    public static ResultEntity ERROR()
    {
        return  new ResultEntity(ResultCode.SERVER_ERROR);
    }

    public static ResultEntity FAIL()
    {
        return  new ResultEntity(ResultCode.FAIL);
    }
}